package com.xueyi.aixihu.pattern;

import com.xueyi.aixihu.constant.SystemRoleConstant;
import com.xueyi.aixihu.entity.vo.DtUsersVo;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述
 *
 * @author 刘梓江
 * @date 2023-12-09 21:50
 */
public class CheckOperationArticleRoleStrategyDirector {

    private static Map<Integer,CheckOperationArticleRoleStrategy> roleStrategyMap;
    static {
        roleStrategyMap=new HashMap<>();
        roleStrategyMap.put(1,ZJDWRoleStrategy.getInstance());
        roleStrategyMap.put(2,ZJZWRoleStrategy.getInstance());
        roleStrategyMap.put(3,CJDWRoleStrategy.getInstance());
        roleStrategyMap.put(4,CJZWRoleStrategy.getInstance());
    }

    /**
     * 获取三务角色适配器
     * @param threeServiceStrategy
     * @return
     */
    public static CheckOperationArticleRoleStrategy getRoleStrategy(int threeServiceStrategy){
        return roleStrategyMap.get(threeServiceStrategy);
    }

    /**
     * 获取当前角色对应管辖的区域的ID
     * @param dtUsersVo
     * @return
     */
    public static String getAreaIdByRoleId(DtUsersVo dtUsersVo){
        if (SystemRoleConstant.SQ.equals(dtUsersVo.getUserMaxRole())){
            //获取社区的第一个区域ID
            return dtUsersVo.findUserManageCommunityId().split(",")[0];

        } else if (SystemRoleConstant.CUN.equals(dtUsersVo.getUserMaxRole())) {
            //获取村的第一个区域ID
            return dtUsersVo.findUserManageAreaId().split(",")[0];

        } else if (SystemRoleConstant.JU_WEI.equals(dtUsersVo.getUserMaxRole())){
            //获取居委的第一个区域ID
            return dtUsersVo.findUserManageJuWeiId().split(",")[0];
        }else {
            //获取镇第一个区域ID
            return dtUsersVo.findUserManageTownId().split(",")[0];
        }
    }
}
